dic = {'k1': 'v1', 'k2': 'v2', 'k3': [11, 22, 33]}
for k in dic.keys():
    print(k)

for v in dic.items():
    # print(type(v))
    print(f"{v[0]}:{v[1]}, ", end=' ')

print()
print("next".center(50, '-'))
dic['k4'] = 'v4'

print(dic)

dic['k1'] = 'kidd'
print(dic)

dic['k3'].append(44)
print(dic)

dic['k3'].insert(0, 18)
print(dic)

print("next".center(50, '-'))

li = [11, 22, 33, 44, 55, 66, 77, 88, 99, 90]
dic = {'key1': [], 'key2': []}
for i in li:
    if i > 66:
        dic['key1'].append(i)
    elif i < 66:
        dic['key2'].append(i)
else:
    print(f"key1:{dic['key1']}key2:{dic['key2']}")

print("next".center(50, '-'))

students = [
    {"name": "张三", "age": 23, "score": 88, "tel": "23423532", "gender": "男"},
    {"name": "李四", "age": 26, "score": 80, "tel": "12533453", "gender": "女"},
    {"name": "王五", "age": 15, "score": 100, "tel": "56453458", "gender": "男"},
    {"name": "赵六", "age": 16, "score": 57, "tel": "86786785", "gender": "不明"},
    {"name": "小明", "age": 18, "score": 98, "tel": "23434656", "gender": "女"},
    {"name": "小红", "age": 23, "score": 72, "tel": "67867868", "gender": "女"},
]


def print_students(dict):
    print(f"name->{dict['name']}\t age->{dict['age']}\t score->{dict['score']}\t tel->{dict['tel']}\t gender->{dict['gender']}")

no_pass_count = 0
no_pass_list = []
no_adult_count = 0
tail_name_list = []
score_list = []

for dict in students:
    if dict['score'] < 60:
        # 1.统计不及格学生的个数
        no_pass_count += 1
        # 2.不及格学生的名字和对应的成绩
        no_pass_list.append((dict['name'],dict['score']))
        # print(f"不及格：{dict['name']}->{dict['score']}")
    # 3.统计未成年学生的个数
    if dict['age'] < 18:
        no_adult_count += 1
    # 4.手机尾号是8的学生的名字
    tel_len = len(dict['tel'])
    if dict['tel'][tel_len - 1] == '8':
        tail_name_list.append(dict['name'])
        # print(f"手机尾号是八：{dict['name']}")
    # 5. 每名学生成绩列表
    score_list.append(dict['score'])


print(f"不及格学生个数：{no_pass_count}")
print(f"不及格学生及成绩：{no_pass_list}")
print(f"未成年的学生个数是:{no_adult_count}")
print(f"手机尾号是8的学生的名字：{tail_name_list}")
# print(score_list)

max_score = max(score_list)
max_index = score_list.index(max_score)
# 5.打印最高分和对应的学生的名字
print(f"{students[max_index]['name']}最高分：{max_score}")


# 6.将students列表按学生成绩从大到小排序
students2 = [
    {"name": "张三", "age": 23, "score": 88, "tel": "23423532", "gender": "男"},
    {"name": "李四", "age": 26, "score": 80, "tel": "12533453", "gender": "女"},
    {"name": "王五", "age": 15, "score": 100, "tel": "56453458", "gender": "男"},
    {"name": "赵六", "age": 16, "score": 57, "tel": "86786785", "gender": "不明"},
    {"name": "小明", "age": 18, "score": 98, "tel": "23434656", "gender": "女"},
    {"name": "小红", "age": 23, "score": 72, "tel": "67867868", "gender": "女"},
]

sorted_score_list = sorted(score_list,reverse=True)
# print(sorted_score_list)
i = 0
for ele in sorted_score_list:
    j = score_list.index(ele)
    students[i] = students2[j]
    i += 1
for dict in students:
    print_students(dict)

# 7.删除性别不明的所有学生
print("next".center(50, '-'))
count = 0
for dict in students:
    if dict['gender'] == '不明':
        students.pop(count)
    count += 1
else:
    for dict in students:
        print_students(dict)


# def 函数名():
#     1
#     2
#     3


